from src.selenium2 import *
# from src.playwright2 import *
# from src.DrissionPage2 import *
from selenium.webdriver.common.by import By
from playwright.sync_api import sync_playwright
import time

if __name__ == '__main__':
    # selenium
    browser = get_browser_2()
    browser.get('https://www.baidu.com/my/index')
    time.sleep(5)

    # browser = get_browser_1()
    # browser.get('https://www.bilibili.com/video/BV1Z4411o7TA')
    # time.sleep(5)
    # # browser.execute_script('window.scrollTo(0, document.documentElement.scrollHeight)')
    # item_list = browser.find_elements(By.CSS_SELECTOR, '#reco_list div.rec-list div.card-box div.pic-box a')
    # random_click(browser, info_list=item_list, css_selector='#reco_list div.rec-list  div.card-box div.pic-box a')
    # time.sleep(5)
    # close_browser(browser)

    # playwright
    # with sync_playwright() as playwright:
    #     browser = get_browser_2(playwright)
    #     browser.goto('https://www.bilibili.com/video/BV1Z4411o7TA')
    #     time.sleep(5)
    #     item_list = browser.locator('#reco_list div.rec-list div.card-box div.pic-box a').element_handles()
    #     random_click(browser, info_list=item_list, css_selector='#reco_list div.rec-list div.card-box div.pic-box a')
    #     time.sleep(5)
    #     close_browser(browser)

    # DrissionPage
    # browser = get_browser_2()
    # browser.get('https://www.bilibili.com/video/BV1Z4411o7TA')
    # time.sleep(5)
    # item_list = browser.eles('css:#reco_list div.rec-list div.card-box div.pic-box a')
    # random_click(browser, info_list=item_list, css_selector='#reco_list div.rec-list div.card-box div.pic-box a', limit=1)
    # time.sleep(5)
    # close_browser(browser)
